package com.lanmon.service.auth;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.lanmon.base.HibernateService;
import com.lanmon.dao.auth.ComStudentDao;
import com.lanmon.entity.ComStudent;
import com.lanmon.entity.ComUser;

@Service
@Component("comStudentService")
public class ComStudentService extends HibernateService<ComStudent,Integer> {
	private ComStudentDao comStudentDao;

	public ComStudentDao getComStudentDao() {
		return comStudentDao;
	}

	@Autowired
	public void setComStudentDao(ComStudentDao comStudentDao) {
		super.setHibernateDao(comStudentDao);
		this.comStudentDao = comStudentDao;
	}
	
	public ComStudent queryByLoginUser(ComUser user){
		if(user == null )
			return null;
		Criterion criterion = Restrictions.eq("comUser.userid",user.getUserid());
		try {
			ComStudent comStudent = findUniqueObject(criterion);
			return comStudent;
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
